import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { BaseResponse} from '@/api/base';

// 定义接口地址
enum Api {
  /** 生成Java代码 */
  GENERATE_JAVA = '/toolkit/genJava',
}

// 定义参数类型

export interface GenerateRequest {
  id?: number;
  moduleName?: String;
  author?: String;
  hasPo?: boolean;
  hasMapper?: boolean;
  hasMapperXml?: boolean;
  hasDo?: boolean;
  hasServiceApi?: boolean;
  hasService?: boolean;
  hasRequest?: boolean;
  hasQuery?: boolean;
  hasController?: boolean;
}

// 定义接口方法: save
// 生成Java代码
export function generateJava(params: GenerateRequest, mode: ErrorMessageMode = 'message') {
  return defHttp.put<BaseResponse<boolean>>(
    {
      url: Api.GENERATE_JAVA,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

